package struts.form;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

public class FullForm {
	public static ActionForm full(String formName, HttpServletRequest request) {
		ActionForm form = null;
		try {
			Class<?> clazz = Class.forName(formName);
			form = (ActionForm)clazz.newInstance();
			Field[] f_ac = clazz.getDeclaredFields();
			for(Field f:f_ac){
				f.setAccessible(true);
				f.set(form, request.getParameter(f.getName()));
				f.setAccessible(false);
			}
		} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
			e.printStackTrace();
		}
		return form;
	}
}
